<template>
  <div class="box">
    <header class="header">
      <van-nav-bar title="详情" left-text="返回" left-arrow @click-left="onClickLeft" />
    </header>
    <main class="content">
      <div><img :src="detailIfo.image" alt="" style="width: 100%;"></div>
      <div>{{ detailIfo.title }}</div>
      <div style="color: red;">￥{{ detailIfo.price }}</div>
    </main>

  </div>
  <van-action-bar>
    <van-action-bar-icon icon="chat-o" text="客服" dot />
    <van-action-bar-icon icon="cart-o" text="购物车" badge="5" />
    <van-action-bar-icon icon="shop-o" text="店铺" badge="12" />
    <van-action-bar-button type="warning" text="加入购物车" @click="Addcart" />
    <van-action-bar-button type="danger" text="立即购买" />
  </van-action-bar>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import request from '@/tool/request'
const detailIfo = ref({})
import { useRoute, useRouter } from 'vue-router';
const route = useRoute()
const router = useRouter()
onMounted(() => {
  request.get('/detail', {
    params: {
      id: route.params.id
    }
  }).then(res => {
    if (res.data.code == 200) {
      detailIfo.value = res.data.data
    }
  })
})
const Addcart=()=>{
  if(localStorage.getItem('token')){
    console.log('已登录');
    
  }else{
    router.push('/login')
  }
}
</script>

<style lang="scss" scoped>
</style>